﻿using System;
using System.Windows.Input;

using rip.View;

namespace rip.ViewModel {
    public class MainViewModel : ViewModelBase {

        public MainViewModel() { 
            //TODO: get drives
            //TODO: loop through drives, each drive gets loaded into a tab
        }

        #region CloseCommand
        RelayCommand closeCommand;
        public ICommand CloseCommand {
            get {
                if (closeCommand == null) {
                    closeCommand = new RelayCommand(param => this.OnRequestClose());
                }
                return closeCommand;
            }
        }
        #endregion

        #region AboutCommand
        RelayCommand aboutCommand;
        public ICommand AboutCommand {
            get {
                if (aboutCommand == null) {
                    aboutCommand = new RelayCommand(param => this.OnRequestAbout());
                }
                return aboutCommand;
            }
        }
        #endregion

        #region EjectCommand
        RelayCommand ejectCommand;
        public ICommand EjectCommand {
            get {
                if (ejectCommand == null) {
                    ejectCommand = new RelayCommand(param => this.OnRequestEject());
                }
                return ejectCommand;
            }
        }
        #endregion

        #region RipCommand
        RelayCommand ripCommand;
        public ICommand RipCommand {
            get {
                if (ripCommand == null) {
                    ripCommand = new RelayCommand(param => this.OnRequestRip());
                }
                return ripCommand;
            }
        }
        #endregion

        #region RequestClose Event
        public event EventHandler RequestClose;
        void OnRequestClose() {
            EventHandler handler = this.RequestClose;
            if (handler != null) {
                handler(this, EventArgs.Empty);
            }
        }
        #endregion

        #region RequestAbout Event
        public event EventHandler RequestAbout;
        void OnRequestAbout() {
            EventHandler handler = this.RequestAbout;
            if (handler != null) {
                handler(this, EventArgs.Empty);
            }
            About about = new About();
            about.ShowDialog();
        }
        #endregion

        #region RequestEject Event
        public event EventHandler RequestEject;
        void OnRequestEject() {
            EventHandler handler = this.RequestEject;
            if (handler != null) {
                handler(this, EventArgs.Empty);
            }
            System.Windows.MessageBox.Show("This will eject the selected drive if possible");
        }
        #endregion

        #region RequestRip Event
        public event EventHandler RequestRip;
        void OnRequestRip() {
            EventHandler handler = this.RequestRip;
            if (handler != null) {
                handler(this, EventArgs.Empty);
            }
            System.Windows.MessageBox.Show("This will rip the selected drive if possible");
        }
        #endregion
    }
}
